﻿/*
 * @Autor: PK
 * @Date: 2021-03-31 13:34:14
 * @Description: 车辆的抽象类，在Customer基础上设置了默认的一些功能，一般和AbstractTraveler一起使用，某则请使用AbstractTraveler
 *               
 */

using System;
using System.Collections.Generic;
using ShkSimulation.core.exceptions;
using ShkSimulation.core.template.agency;
using ShkSimulation.core.template.customer;

namespace ShkSimulation.carsharing {
    
    public abstract class CarsharingVehicle : Customer{

        public CarsharingVehicle(int id) {
            this.Id = id;
        }
        public CarsharingTraveler Traveler { get; private set; }
        public int CurrentSegmentIndex { get; internal set; } = -1;
        public DateTime TimeStartServe { get; set; }
        public DateTime TimeLeaveStation { get; set; }

        public void BindCustomer(CarsharingTraveler traveler) {
            if (traveler == null) {
                throw new ErrorParamException("幽灵车");
            }
            traveler.Vehicle = this;
            this.Traveler = traveler;
        }
        
        public void UntieCustomer() {
            if (Traveler == null) {
                throw new ErrorParamException("幽灵车");
            }
            Traveler.Vehicle = null;
            this.Traveler = null;
        }
        
        public override IReadOnlyList<Agency> GetAgencies() {
            throw new ErrorParamException("请使用Traveler调用");
        }

        public override void EnterNextAgency() {
            throw new ErrorParamException("请使用Traveler调用");
        }
        
        public override Agency PeekNextAgency() {
            throw new ErrorParamException("请使用Traveler调用");
        }

        
        public override void SkipAgency(int count) {
            throw new ErrorParamException("请使用Traveler调用");
        }

        public abstract void UpdateBattery();
        public abstract bool BatteryEnough(DateTime clockTime, double demand);
    }
}
